package com.example.wanandroid_copy2.ui.login.data.model

object LoginSucState {

    var listeners =  ArrayList<LoginSucListener>()

    fun addListener(listener: LoginSucListener) {
        listeners.add(listener)
    }

    fun removeListener(listener: LoginSucListener) {
        listeners.remove(listener)
    }

    // 利用观察者模式来进行状态的变更
    fun notifyLoginState(name: String, collectIds: List<Int>?) {
        for (listener in listeners) {
            listener.loginSuccess(name, collectIds)
        }
    }
}